package Month09.day0902;

import java.util.Arrays;
import java.util.Scanner;

public class NiuKe {
    public static void main(String[] args) {
        //KiKi想从n行m列的方阵队列中找到身高最高的人的位置，请你帮助他完成这个任务。
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[][] c = new int[a][b];
        int count1 = 0;//记录最大身高所在行数
        int count2 = 0;//记录最大身高所在列数
        int max = 0;
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                c[i][j] = sc.nextInt();
                if(c[i][j] > max){
                    count1 = i;
                    count2 = j;
                    max = c[i][j];
                }
            }
        }
        count1 +=1;
        count2 +=1;
        System.out.print(count1 +" " + count2);
    }//BC104 最高身高
    public static void main5(String[] args) {
        //KiKi现在得到一个包含n*m个数的整数序列，现在他需要把这n*m个数按顺序规划成一个n行m列的矩阵并输出，请你帮他完成这个任务。
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[]  a  = new int[m*n];
        for (int i = 0; i < a.length; i++) {
                a[i] = sc.nextInt();
        }
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
            if((i + 1) % n == 0){
                System.out.println();
            }
        }
    }//BC103 序列重组矩阵
    public static void main4(String[] args) {
        //KiKi得到了一个n行m列的矩阵，现在他想知道第x行第y列的值是多少，请你帮助他完成这个任务。
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] a = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                    a[i][j] = sc.nextInt();
            }
        }
        m = sc.nextInt();
        n = sc.nextInt();
        System.out.println(a[m - 1][n - 1]);
    }//BC102 矩阵元素定位
    public static void main3(String[] args) {
        //输入一个班级5个学生各5科成绩，输出5个学生各5科成绩及总分。
        Scanner sc = new Scanner(System.in);
        double[][] a = new double[5][5];
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                a[i][j] = sc.nextDouble();
            }
        }
        for (int i = 0; i < 5; i++) {
            double res = 0;
            for (int j = 0; j < 5; j++) {
                System.out.print(a[i][j] + " ");
                res += a[i][j];
            }
            System.out.println(res);
        }
    }//BC101 班级成绩输入输出
    public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
       /* //接收两个数组总数
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[m + 1];
        int[] b = new int[n + 1];
        //接收数组数
        for (int i = 0; i < m; i++) {
                a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
                b[i] = sc.nextInt();
        }
        int[] c = new int[m + n];//创建新数组用来排序
        int count = 0;//用count来进行数组的下标排序
        int count1 = 0; //进行数组a
        int count2 = 0; //进行数组b
        while(count < m+n){
            if(a[count1] > b[count2]){
                c[count] = b[count2];
                count2++;
                count++;
                continue;
            }else if(a[count1] < b[count2]){
                c[count] = a[count1];
                count1++;
                count++;
                continue;
            }else if(a[count1] == 0){
                c[count] = b[count2];
                count++;
                continue;
            }else if(b[count2] == 0){
                c[count] = a[count1];
                count++;
                continue;
            }

        }
        for(int i:c){
            System.out.print(i + " ");
        }
        sc.close();*/  //失败的尝试
        int[] a = new int[sc.nextInt() + sc.nextInt()];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i:a){
            System.out.print(i + " ");
        }
    }//BC100 有序序列合并
    public static void main1(String[] args) {
        //输入n个整数的序列，要求对这个序列进行去重操作。所谓去重，是指对这个序列中每个重复出现的整数，只保留该数第一次出现的位置，删除其余位置。
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            int a = sc.nextInt();//用来接收数组的总个数
            int[] arr = new int[a];
            for (int i = 0; i < a; i++) {
                arr[i]  = sc.nextInt();//用来接收输入数字
            }
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < a; j++) {
                    if((i != j) && (arr[i] == arr[j])){
                        arr[j] = 0;
                    }
                }//两个循环用来检验
            }
            for (int i = 0; i < a; i++) {
                if(arr[i] != 0){
                    System.out.print(arr[i] + " ");
                }
            }
        }
        sc.close();
    }//BC99 序列中整数去重
}
